﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class PasswordReset : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnPassReset_Click(object sender, EventArgs e)
    {
     
            if (Request.QueryString["UserID"] != null)
            {
                var PasswordRecovery = new DealesDataContext();
                var DealDesp = PasswordRecovery.Password_Update(new Guid(Request.QueryString["UserID"].ToString()));
                string username="";
                foreach (var item in DealDesp)
                {
                    username = item.UserName;
                }
                MembershipUser mc = Membership.GetUser(username);

                // MemberShipProvider
                MembershipProvider mp = Membership.Provider;
                // Un Locking User Method
                mp.UnlockUser(Request.QueryString["UserID"].ToString());
                // Reset Password Method
                string stPwd = mc.ResetPassword();
                // Change Password Method
                if (mc.ChangePassword(stPwd, txtPassword.Text))
                {
                    Response.Redirect("Login.aspx");
                }
                else
                {
                    Response.Write("The Entered Password Is Not Updated!");
                }
            }
                //    Membership.GetUser().ChangePassword(Membership.GetUser().GetPassword(), txtPasswordChange.Text);

           }
  
   }
    
    

